# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=scribus
pkgver=1.5.8
pkgrel=28
pkgdesc="libre desktop publishing"
url="https://www.scribus.net/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # no test
makedepends="cmake boost-dev cairo-dev cups-dev harfbuzz-dev hunspell-dev
	lcms2-dev libcdr-dev libfreehand-dev libmspub-dev libpagemaker-dev
	libqxp-dev libvisio-dev libzmf-dev mesa-dev poppler-dev qt5-qttools
	qt5-qttools-dev qt5-qtbase-dev python3-dev samurai"
subpackages="$pkgname-doc $pkgname-lang"
source="
	https://downloads.sourceforge.net/scribus/scribus-$pkgver.tar.xz
	musl-types.patch
	no-execinfo.patch
	poppler-22.02-1.patch
	poppler-22.02-2.patch
	poppler-22.03.patch
	poppler-22.04.patch
	poppler-22.09.patch
	"

langdir="/usr/share/scribus/translations"
build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DWANT_DISTROBUILD=True \
		-DWANT_CPP17=True \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
eb46be0165eeb0d8974aa744fc8ffac321b206ca0015da39bb2f50d9fd4a5e28300a49ada0f963b4e0cf9a3301dc746ffba74f359f5e76d308d80b71ee669c2d  scribus-1.5.8.tar.xz
5d01d2da8ba569efa3809d8fbfe83bfb011516edd4297ad50eb1a1b560c803e4db8e7d9bf71b2520bf65e8eaa28f6d5baaa1215091d1826ed49af1c511400767  musl-types.patch
3ed888fae0212681de8808c928464e2c1387bff3a3f2ea5fd31ba7f3d21594a2d70d2a801e4c9f8d6c5e11c3c75adae30db0690db8cf21fb982c1812c8db37e5  no-execinfo.patch
d854a141ddfb66e079bf5f1bf4b8ae6c6c2384838033b423aebbfa78cdc93d649a2979df790b67f1b8ceb6865dfed40a5d42deeb2a7fd3f675b6a5f82d6f5264  poppler-22.02-1.patch
8e91318722006af7ad034bc6f17f331978cd169b6435f148631d2016b03f5207990d4e07fa4ad5ce26dc1c2fcdda8d3aa1689374146da9d181733254f5ca005a  poppler-22.02-2.patch
a441e281555b5ae640e275e130424ffb35975825fa530a40dc051fec6cc0aaa0303f7fb7e6ef767abd4ed661c95aacc8f3dfe7e35e858450a8bf5ce493480175  poppler-22.03.patch
8c13e54b62ea0aebaff9a4f55742159906218bc920c19c9467b975d2e182fe2ea72e71adf29506b9c9a88fb7367365a1bc018d1774f56bb4c4ed6100b97d72d2  poppler-22.04.patch
1600ae7269474cd8dc3d0322da2687c0a88ed14f61c458724bd7a4a4cfc612029e2aad8177828916b1c74dff85b89f82a51363741ea704b18014bba34fbbd77e  poppler-22.09.patch
"
